package com.hsy.sunflowerbao.base.ui.widget

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater

import com.hsy.sunflowerbao.R

/**
 * 自定义进度条对话框
 * Created on 2017/12/4.
 *
 * @author Yang
 */
class ProgressDialog(context: Context?) : Dialog(context, R.style.progress_dialog) {
    private var animationStop = false
    private var animationReplay = false

    init {
        val contentView = LayoutInflater.from(context).inflate(R.layout.my_progress_dialog, null)
        setContentView(contentView)
//        progressImage.animate()
//                .setInterpolator(LinearInterpolator())
//                .setListener(object : Animator.AnimatorListener {
//                    override fun onAnimationStart(animation: Animator) {
//
//                    }
//
//                    override fun onAnimationEnd(animation: Animator) {
//                        if (!animationStop) {
//                            animationReplay = if (!animationReplay) {
//                                progressImage!!.animate().rotation(0f).setDuration(1).start()
//                                true
//                            } else {
//                                progressImage!!.animate().rotation(360f).setDuration(1000).start()
//                                false
//                            }
//                        }
//                    }
//
//                    override fun onAnimationCancel(animation: Animator) {
//
//                    }
//
//                    override fun onAnimationRepeat(animation: Animator) {
//
//                    }
//                })
        setCancelable(false)
        setCanceledOnTouchOutside(false)
    }

    public override fun onStart() {
        super.onStart()
        animationStop = false
//        progressImage!!.animate().rotation(360f).setDuration(1000).start()
    }

    public override fun onStop() {
        super.onStart()
        animationStop = true
//        progressImage!!.animate().cancel()
    }
}